import os

def search_files(root_dir):
    # 遍历目录
    for dirpath, dirnames, filenames in os.walk(root_dir):
        print("dirpath", dirpath)
        print("dirnames", dirnames)
        print("filenames", filenames)
        continue
        # 找到包含changlog文件夹的这一层，就是总的xml所处的文件夹，在这里执行liqiubase命令即可
        if dirnames == ['changelog']:
            data_base = dirpath.split("\\")[-1]
            if data_base in filenames[0]:
                print(os.path.join(dirpath, filenames[0]))
        for filename in filenames:
            pass
            # print(os.path.join(dirpath, filename))


if __name__ == '__main__':
    change_log_dir = sys.argv[1]
    # change_log_dir = r"E:\H.恒康信息科技\B.版本相关\F.升级记录\Z.中台相关\J.二代脚本\V2.48\表结构\V2.48\20240417140655"
    if os.path.exists(change_log_dir):
        search_files(change_log_dir)